package com.jcroke.pc3EvalEngine;

import com.gadberry.jexel.expression.Argument;
import com.gadberry.jexel.expression.ArgumentCastException;
import com.gadberry.jexel.expression.Expression;
import com.gadberry.jexel.expression.InvalidExpressionException;

public class Eval {

	private String expr;

	public Eval(String expr) {
		this.expr = expr;
	}

	public Argument process() {

		Argument ret = null;
		try {
			ret = Expression.evaluate(expr);
		} catch (ArgumentCastException e) {
			System.out.println(e.getMessage());
		} catch (InvalidExpressionException e) {
			System.out.println(e.getMessage());
		}
		return ret;
	}

	public static void main(String[] args) {

		Eval e = new Eval(args[0]);
		Argument a = e.process();
		System.out.println("answer: " + a.toString());
	}
}
